package com.lzw.breezeNovel.webApp.controller.video;

import com.lzw.breezeNovel.common.result.Result;
import com.lzw.breezeNovel.model.entity.query.PaginationResultQuery;
import com.lzw.breezeNovel.model.entity.query.video.CommnetQuery;
import com.lzw.breezeNovel.webApp.service.video.VideoCommentService;
import com.lzw.breezeNovel.webApp.vo.video.VideoCommentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 清风明月
 * @Package com.lzw.breezeNovel.webApp.controller.video
 * @date 2025/3/19
 * @description 评论
 */
@RestController
@RequestMapping("/app/video/comment")
@SuppressWarnings("all")
public class VideoCommentController {

    /**
     * 评论服务
     */
    @Autowired
    private VideoCommentService videoCommentService;

    /**
     * 分页获取评论
     */
    @PostMapping("/list")
    public Result<List<VideoCommentVo>> list(@RequestBody CommnetQuery commnetQuery){
        List<VideoCommentVo> videoCommentVos = videoCommentService.list(commnetQuery);
        return Result.ok(videoCommentVos);
    }

    /**
     * 添加评论
     */
    @GetMapping("/add")
    public Result add(@RequestParam Integer type, @RequestParam String content,@RequestParam Long videoId){
        videoCommentService.add(type, content, videoId);
        return Result.ok();
    }

    /**
     * 根据用户id获取评论
     */
    @GetMapping("/listByUserId")
    public Result<PaginationResultQuery<VideoCommentVo>> listByUserId(@RequestParam Integer pageNo, @RequestParam Integer size){
        PaginationResultQuery<VideoCommentVo> paginationResultQuery = videoCommentService.listByUserId(pageNo,size);
        return Result.ok(paginationResultQuery);
    }

    /**
     * 根据评论id逻辑删除用户已经看过的评论
     */
   @DeleteMapping("/delete")
   public Result delete(@RequestParam Long commentId){
       videoCommentService.delete(commentId);
       return Result.ok();
   }


}
